/*
 * ImageLayout.h
 *
 *  Created on: 22.10.2012
 *      Author: caffeine
 */

#ifndef IMAGELAYOUT_H_
#define IMAGELAYOUT_H_

#include <irrlicht.h>
#include "ImageLayout.h"
#include <thread/IThread.h>

class CompositeImage:public virtual irr::IReferenceCounted{
private:
	irr::thread::IMutex*load_mutex;
	irr::thread::IThread*lastThread;
	irr::IrrlichtDevice*device;
	irr::core::dimension2du Size;
	bool changed;
	irr::video::IImage*stage;
	irr::video::ITexture*texture;
	irr::core::array<ImageLayout*>list;

	friend class ImageLayout;

public:
	ImageLayout*add(irr::core::position2di position=irr::core::position2di(0,0),irr::io::path path="");
	void add(ImageLayout*layout);
	ImageLayout*get(irr::u32 index);
	irr::u32 size();
	void remove(irr::u32 index);
	void remove(ImageLayout*layout);
	irr::s32 indexOf(ImageLayout*layout);
	void setSize(irr::core::dimension2du size);
	CompositeImage(irr::IrrlichtDevice*device,irr::core::dimension2du size);
	irr::video::ITexture*getTexture();
	irr::video::IImage*getStage();
	void updateTexture();
	bool updateTexture_unsync(irr::thread::ITask*task);
	virtual ~CompositeImage();
};

#endif /* IMAGELAYOUT_H_ */
